﻿using System;
using System.Collections.Generic;

class SequenceOfGivenSum
{
    static void Main()
    {
        Console.WriteLine("Enter the number of elements of the array:");
        int arrayLength = int.Parse(Console.ReadLine());
        int[] arrayOfInts = new int[arrayLength];
        for (int index = 0; index < arrayLength; index++)
        {
            Console.WriteLine("Enter element {0}", index);
            arrayOfInts[index] = int.Parse(Console.ReadLine());
        }
        Console.WriteLine();
        Console.WriteLine("Enter the sum you are looking for:");
        int Sum = int.Parse(Console.ReadLine());
        for (int i = 0; i < arrayLength-1; i++)
        {
            int middleSum = arrayOfInts[i];
            for (int j = i+1; j < arrayLength; j++)
            {
                middleSum += arrayOfInts[j];
                if (middleSum == Sum)
                {
                    Console.WriteLine();
                    Console.WriteLine("Sequence found:");
                    for (int z = i; z <= j; z++)
                    {

                        Console.WriteLine(arrayOfInts[z]);
                    }
                }
            }
        }
    }
}

